package junit;

import org.junit.Test;
import pojo.Book;
import service.BookService;
import service.impl.BookServiceImpl;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author Wxt
 * @create 2022-02-09 20:58
 */
public class BookServiceTest {
    private BookService bookService = new BookServiceImpl();

    @Test
    public void addBook() {
        bookService.addBook(new Book(null, "数据结构", "白学明", new BigDecimal(45), 100, 33, null));
        System.out.println("添加成功");
    }

    @Test
    public void deleteBookById() {
        bookService.deleteBookById(24);
        System.out.println("删除成功");
    }

    @Test
    public void updateBook() {
        bookService.updateBook(new Book(24, "数据结构", "白学明", new BigDecimal(45), 103, 30, null));
        System.out.println("修改成功");
    }

    @Test
    public void queryForOneById() {
        Book book = bookService.queryForOneById(24);
        System.out.println(book);
    }

    @Test
    public void queryAllBooks() {
        List<Book> books = bookService.queryAllBooks();
        for (Book book : books) {
            System.out.println(book);
        }
    }
}